<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="author" content="wangbo">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>数据转化</title>
</head>

<body>
  <script>

    // 字符串 类型转化成数字
    // 其他类型转化成 number 只能是纯数字的字符串
    // 转化不成功 是NaN not a number
    let strNum = Number('100.22')
    console.log(strNum, typeof strNum);
    // 布尔类型转化数字 boolean true|false true 1 false 0 
    let isNum = Number(false)
    console.log(isNum, typeof isNum);
    console.log(Number(true), typeof Number(true));
    // null 转化数字  是 0
    let nullNum = Number(null)
    console.log(nullNum, typeof nullNum);
    // undefined  无法转化成数字  NaN
    let myUndefined = undefined;
    let nuNum = Number(myUndefined)
    console.log(nuNum, typeof nuNum);
    // 直接会 报错 Cannot convert a Symbol value to a number
    let ss = Symbol()
    let ssNum = Number(ss)

    // 无法转化成功 NaN
    // let numundefinedl = Number(undefined)
    // console.log(numundefinedl)

    // Cannot convert a Symbol value to a number
    // let numsymbol = Number(Symbol("111"))

    // console.log(numsymbol)

    console.log(1 * "123");
    // console.log(1*true);
    // console.log(1*false);
    // console.log(1*null);
    // console.log(1*undefined);

  </script>
</body>

</html>